package com.viphome;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.nio.charset.Charset;

@Controller
@SpringBootApplication//默认扫描，本类所在文件夹及子目录中的注解,
                      //（exclude = RedisConfiguration.class）
@Configuration
public class SpringBootHellowordApplication {

	private Logger log = LoggerFactory.getLogger(this.getClass());

	@RequestMapping("hello")
	@ResponseBody
	public String hello(){
		log.info("info日志");
		log.debug("debug日志");
		log.error("error日志");
		return "hello world！传智播客";
	}

	//中文会进入消息转发,如果用ISO-8859-1，就会乱码
	@Bean
	public StringHttpMessageConverter stringHttpMessageConverter(){
		StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
//		StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("ISO-8859-1"));
		return converter;
	}

	public static void main(String[] args) {
		SpringApplication.run(SpringBootHellowordApplication.class, args);
	}
}
